package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) throws IOException {
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("test2.txt",true));
        System.out.println("请输入字符串，如需要单独输入“exit”退出！！！");
        String str = null;
        while(true){
            str = new Scanner(System.in).nextLine();
            if("exit".equalsIgnoreCase(str)){
                System.out.println("退出输入！！！");
                break;
            }
            osw.write(str);
        }
        System.out.println("写出完毕！！！");
        osw.close();
    }
}
